package net.javashop.web.context;

import javax.servlet.ServletContext;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
/**
 * Spring上下文环境
 * @author wqq
 * @see net.javashop.web.listener.SpringContextLoaderListener
 */
public class SpringContext {
	
	private static ApplicationContext applicationContext;  //Spring应用上下文环境
	private static ServletContext servletContext;

	public static void setApplicationContext(ApplicationContext ct)
			throws BeansException {
		applicationContext = ct;
	}

	public static ApplicationContext getApplicationContext() {
		return applicationContext;
	}

	public static Object getBean(String name) throws BeansException {
		return applicationContext.getBean(name);
	}

	public static ServletContext getServletContext() {
		return servletContext;
	}

	public static void setServletContext(ServletContext servletContext) {
		SpringContext.servletContext = servletContext;
	}

}
